package com.hycreate.platform.modules.crm.project;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hycreate.platform.common.service.CrudService;
import com.hycreate.platform.modules.sys.entity.Dict;
@Service
@Transactional(readOnly = true)
public class ProjectContactService extends CrudService<ProjectContactDao, ProjectContact> {
	@Autowired
	private ProjectContactDao projectContactDao;
	/**
	 * 查询项目所有联系记录
	 * @param project
	 * @return
	 */
	public List<ProjectContact> findAllProjectContact(Project project){
		return projectContactDao.findAllProjectContact(project);
	}
	/**
	 * 查找项目所在公司的所有联系人详细信息
	 * @param id
	 * @return
	 */
	public List<Contact> findCustomer(ProjectContact projectcontact){
		return projectContactDao.findinfo(projectcontact);
	}
	
	/**
	 * 查找关于项目的所有状态
	 */
	public List<Dict> findDict(){
		return projectContactDao.findDict();
	}
	/**
	 * 查询项目所在公司的联系人姓名及id
	 * @param project
	 * @return
	 */
	public List<Contact> findContact(Project project){
		return projectContactDao.findContact(project);
	}
	
	
	/*@Transactional(readOnly = false)
	public int addcontact(ProjectContact projectContact){
		return projectContactDao.insert(projectContact);
	}*/
	/**
	 * 添加项目联系记录
	 */
	@Transactional(readOnly = false)
	public void addcontact(ProjectContact projectContact) {
		if (projectContact.getIsNewRecord()){
			projectContact.preInsert();
			dao.insert(projectContact);
		}else{
			projectContact.preUpdate();
			dao.update(projectContact);
		}
	}
	
}
